﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CanDoo.Data.Entity;
using CanDoo.Oil.Core.Models;

namespace CanDoo.Oil.Core.ModelConfigurations
{
    /// <summary>
    /// 实体类-数据表映射——采购结算单
    /// </summary>
    public class BuyStatementConfiguration : EntityConfigurationBase<BuyStatement>
    {
        /// <summary>
        /// 初始化一个<see cref="BuyStatementConfiguration"/>类型的新实例
        /// </summary>
        public BuyStatementConfiguration()
        {
             ToTable("finance_BuyStatement");
             this.Property(p => p.SupplierId).HasColumnName("SupplierId");
             this.HasRequired(p => p.Supplier).WithMany().HasForeignKey(p => p.SupplierId).WillCascadeOnDelete(false);

             this.Property(p => p.PayTypeId).HasColumnName("PayTypeId");
             this.HasRequired(p => p.PayType).WithMany().HasForeignKey(p => p.PayTypeId).WillCascadeOnDelete(false);

             this.Property(p => p.UserId).HasColumnName("UserId");
             this.HasRequired(p => p.User).WithMany().HasForeignKey(p => p.UserId).WillCascadeOnDelete(false);

             this.Property(p => p.BuyAdvanceMoneyId).HasColumnName("BuyAdvanceMoneyId");
             this.HasOptional(p => p.BuyAdvanceMoney).WithMany().HasForeignKey(p => p.BuyAdvanceMoneyId).WillCascadeOnDelete(false);

        }
    }
}
